package com.ivy.irublesson.adapter;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ivy.irublesson.R;
import com.ivy.irublesson.entity.Teacher;

import java.util.List;

/**
 * Created by admin on 2018/1/9.
 */

public class TeacherAdapter extends BaseAdapter {
    //private Context ctx;
    private Activity ctx;
    private List<Teacher> teachers;

    public TeacherAdapter(Activity ctx, List<Teacher> teachers){
        this.ctx = ctx;
        this.teachers = teachers;

    }



    @Override
    public int getCount(){

        return teachers.size();
    }
    @Override
    public Object getItem(int i){
        return teachers.get(i);
    }
    @Override
    public long getItemId(int i){
        return i;
    }
    @Override
    public View getView(int position, View convertvView, ViewGroup parent){
        View v = null;
        if (convertvView == null){
            v = ctx.getLayoutInflater().inflate(R.layout.item_teach,null,false);
        }else {
            v = convertvView;
        }
        Teacher t = teachers.get(position);

        TextView teach_teacherid = (TextView) v.findViewById(R.id.teach_teacherid);
        teach_teacherid.setText(t.getTid());
        TextView teach_name = (TextView) v.findViewById(R.id.teach_name);
        teach_name.setText(t.getTname());
        return v;
    }

}
